package com.wenye.service;

import com.wenye.dao.UserDao;
import com.wenye.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService{
    @Autowired
    private UserDao userDao;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public User login(User user){
        System.out.println("service:username:"+user.getUsername());
        User userDB = userDao.login(user);
        if(userDB != null){
            return userDB;
        }
        throw new RuntimeException("认证失败");
    }
}
